﻿@using SH = EMoney.IStock.Client.Framework.StringHelper;

@{
    Layout = null;

    int userid = ViewBag.UserID;
    string qq = ViewBag.QQ;
    string associatedlogin = ViewBag.Associatedlogin;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>腾讯A股大赛报名</title>
    <link rel="stylesheet" type="text/css" href="@ViewBag.PageCss" id="linkcss" />
    @*<link rel="stylesheet" type="text/css" href="@SH.GetStaticFile("IStockClientStatic/qq/css/default.css")" />*@
    <script src="http://static.emoney.cn/js/libs/jquery.min.1.8.3.js" type="text/javascript"></script>
</head>
<body>
    <div class="" style="width:800px;margin:0 auto;">
        <div class="game" style="height:640px;">
            <div class="game_box">
                <!--game_top-->
                <div class="game_top">
                    <div class="game_top_left">
                        <!--游客状态-->
                        @{
                            if (userid == 0)
                            {
                            <h3>您当前还是 <span>游客</span> 状态，登录后即可报名参赛</h3>
                            <p class="game_top_left_font"><a hidefocus="true" href="javascript:;" class="login">立即登录</a></p>
                            }
                            else
                            {
                            <ul class="game_verify">
                                @{
                                if (string.IsNullOrEmpty(qq))
                                {
                                    <li class="game_verify_title02"><b>QQ：未绑定</b>@*<span>绑定QQ</span>*@</li>
                            
                                    if (associatedlogin == "0")
                                    {
@*<li><input type="text" id="pwd" class="game_verify_input02" maxlength="20" value="软件登录密码" /></li>*@
                                    }
                                
                                    <li class="game_verify_font02" style="margin-left: 12px; color: red;"><span id="spanMsg"></span></li>
                                    <li><a hidefocus="true" href="javascript:;" class="game_verify_a02" style="font-size: 17px;" id="bindqq">绑定QQ</a></li>
                                }
                                else
                                {
@*<li class="game_verify_title">股霸天下</li>*@
                                    <li class="game_verify_font">QQ：@qq</li>
                                    <li>
                                        <input type="text" class="game_verify_input02" id="mobile" maxlength="11" value="请输入手机号码" /></li>
                                    <li>
                                        <input type="text" class="game_verify_input" id="code" maxlength="6" /><a hidefocus="true" href="javascript:;" class="game_verify_a" id="getcode">获取手机验证码</a></li>
                                        <li class="game_verify_font02" style="margin-left: 10px;">
                                        <input type="checkbox" id="ckbm" /><label for="ckbm" hidefocus="true">我已了解并同意报名须知内容</label></li>
                                    <li class="game_verify_font02 red" style="margin-left: 12px;"><span id="spanMsg"></span></li>
                                    <li style="text-align: center;"><a hidefocus="true" href="javascript:;" class="game_verify_a02" id="bntbm">我要报名</a></li>
                                }
                                }
                            </ul>
                            }
                        }
                    </div>
                    <div class="game_top_right">
                        <h3>立刻报名，多得10万虚拟盘参赛资金！</h3>
                        <ul class="game_top_rignt_A">
                            <li><em>1</em><span>QQ登录</span></li>
                            <li><em>2</em><span>手机验证</span></li>
                            <li><em>3</em><span>报名成功</span></li>
                        </ul>
                        <h4 style="margin-top: 8px;">报名须知</h4>
                        <ul class="game_top_rignt_B">
                            <li>1、在此页面报名，可多获得10万虚拟参赛资金；</li>
                            <li>2、比赛系统默认使用QQ昵称作为参赛名；</li>
                            <li>3、报名须验证手机号码， 每个号码仅限报名一次；</li>
                            <li>4、报名成功后，即可获得一次话费抽奖机会；</li>
                            <li>4、活动最终解释权归主办方所有。</li>
                        </ul>
                    </div>
                </div>
                <!--game_top end-->
                <!--privilege-->
                <div class="privilege">
                    <h2 style="height:23px;"><span style="position:absolute;">参赛特权</span><b style="width:720px;left:40px;position:absolute;z-index:-1;"></b></h2>
                    <ul>
                        <li>
                            <div class="privilege_li_box"></div>
                            <p class="privilege_li_box_font">高手实时数据</p>
                        </li>
                        <li>
                            <div class="privilege_li_box"></div>
                            <p class="privilege_li_box_font">高手实时数据</p>
                        </li>
                        <li>
                            <div class="privilege_li_box"></div>
                            <p class="privilege_li_box_font">高手实时数据</p>
                        </li>
                        <li>
                            <div class="privilege_li_box"></div>
                            <p class="privilege_li_box_font">高手实时数据</p>
                        </li>
                    </ul>
                </div>
                <!--privilege end-->
            </div>
        </div>
    </div>
    <div class="go" id="go" style="display: none;">
        <h3>大赛报名<span>X</span></h3>
        <ul>
            <li class="go_title">报名成功</li>
            <li>恭喜您获得 1,000,000万 虚拟资金</li>
            <li class="go_font"><a hidefocus="true" href="javascript:;">确 定</a></li>
        </ul>
    </div>
    <div class="bindqqpopup" id="popup" style="display: none; width: 700px; height: 440px;">
        <h3 style="width: 690px;"><span>绑定QQ</span><b id="popup_close"></b></h3>
        <iframe id="bindiframe" frameborder="0" border="0" width="700" height="435"></iframe>
    </div>
    <input type="hidden" id="hidQQ" value="@qq" />
    <input type="hidden" id="hidUserID" value="@userid" />
    <input type="hidden" id="hidColor" value="@ViewBag.Color" />
    <input type="hidden" id="hidAssociatedlogin" value="@associatedlogin" />
    <input type="hidden" id="hidN" value="b570fe04448f2787e6857be7c5dc6f4eccd66ff6922a7b08094716a8c7ffe0cdaadb68c8716cf151cad9c99a2cce28b9182b1b3b52ae597847012be6ae62350bb3842c3af853f4ab68e086afcf9efd28785f39038f25aaff42e60b7bf424f3a8f5b33dd996836b4985ae7c52c003d8de249ab767af1eda382212200599135cbf" />
    <input type="hidden" id="hidE" value="010001" />

    <script type="text/javascript" src="@SH.GetStaticFile("IStockClientStatic/js/jquery.blockUI.js")"></script>
    <script src="@SH.GetStaticFile("IStockClientStatic/js/rasall.js")" type="text/javascript"></script>
    <script type="text/javascript" src="@SH.GetStaticFile("IStockClientStatic/js/istockfunc.js")"></script>
    @*<script src="@SH.GetStaticFile("IStockClientStatic/js/artDialog.js")" type="text/javascript"></script>
    <script src="@SH.GetStaticFile("IStockClientStatic/js/artDialog.iframeTools.js")" type="text/javascript"></script>    *@
</body>
</html>
<script type="text/javascript">
    var www = "@Url.Content("~/")", associatedlogin = $("#hidAssociatedlogin").val(), userid = $("#hidUserID").val(),
        qq = $("#hidQQ").val(), hidColor = $("#hidColor").val(), countdownNum = 60, sendflag = "";

    $(document).ready(function () {
        $("#pwd").focus(function () {
            if ($(this).val() == "软件登录密码") {
                $(this).val("");
            }
        });

        $("#pwd").blur(function () {
            if ($(this).val() == "") {
                $(this).val("软件登录密码");
            }
        });

        $("#mobile").focus(function () {
            if ($(this).val() == "请输入手机号码") {
                $(this).val("");
            }
        });

        $("#mobile").blur(function () {
            if ($(this).val() == "") {
                $(this).val("请输入手机号码");
            }
        });

        $("#bindqq").click(function () {
            $("#spanMsg").html("");

            var left = (document.body.clientWidth - 700) / 2;
            var top = (document.body.clientHeight - 440) / 2;

            $.blockUI({ message: $('#popup'), css: { top: top, left: left, width: '700', height: '440' } });

            var returnurl = "http://dsclient.emoney.cn/IStockClient/qq/bind?p=" + rsaFunc(userid + "^0^" + associatedlogin + "^" + hidColor);

            $("#bindiframe").attr("src", "http://i.emoney.cn/istockoauth/qq?returnurl=" + returnurl);
        });

        $("#popup_close").click(function () {
            $.unblockUI();
            $(".blockUI").fadeOut("slow");

            window.location.href = www + "qq";
        });

        $(".login").click(function () {
            ISTOCK_FUNC_LOGIN();
        });

        $("#getcode").click(function () {
            if ($(this).hasClass("done")) {
                return;
            }

            var mobile = $("#mobile").val();

            if (mobile == "" || mobile == "请输入手机号码") {
                $("#spanMsg").html("请输入手机号码");
            }
            else if (!mobile.match(/^1[3|4|5|8][0-9]\d{4,8}$/)) {
                $("#spanMsg").html("手机号格式错误");
            }
            else {
                $.ajax({
                    type: "post",
                    url: www + "qq/code",
                    data: { m: mobile },
                    datatype: "text",
                    success: function (data) {
                        if (data == "0") {
                            $("#spanMsg").html("验证码发送成功");

                            countdownNum = 60;
                            countdown();

                            $("#getcode").addClass("done");
                            sendflag = "1";
                        }
                        else {
                            $("#spanMsg").html(data);
                        }
                    },
                    beforeSend: function () {
                        sendflag = "0";
                        $("#spanMsg").html("验证码发送中...");
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        //alert(XMLHttpRequest.status);
                    }
                });
            }
        });

        $("#bntbm").click(function () {
            var mobile = $("#mobile").val();
            var code = $("#code").val();

            if (sendflag != "1") {
                $("#spanMsg").html("请先获取验证码");

                return false;
            }
            else if (mobile == "" || mobile == "请输入手机号码") {
                $("#spanMsg").html("请输入手机号码");

                return false;
            }
            else if (!mobile.match(/^1[3|4|5|8][0-9]\d{4,8}$/)) {
                $("#spanMsg").html("手机号码格式错误");

                return false;
            }
            else if (code == "") {
                $("#spanMsg").html("请输入验证码");

                return false;
            }
            else if ($("#ckbm").attr("checked") != "checked") {
                $("#spanMsg").html("请勾选了解并同意报名须知内容");

                return false;
            }
            else {
                $.ajax({
                    type: "post",
                    url: www + "qq/reg",
                    data: { code: code, tel: mobile },
                    datatype: "text",
                    success: function (data) {
                        if (data == "0") {
                            window.location.href = www + "qq?color=" + hidColor;
                        }
                        else {
                            $("#spanMsg").html(data);
                        }
                    },
                    beforeSend: function () {
                        $("#spanMsg").html("报名中...");
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        //alert(XMLHttpRequest.status);
                    }
                });
            }
        });
    });

    function OnSkinChanged(skinName) {
        var cssHref = "";

        switch (skinName) {
            case "default":
                hidColor = skinName;
                cssHref = $("#hidWhiteCss").val();
                break;
            case "black":
                hidColor = skinName;
                cssHref = $("#hidBlackCss").val();
                break;
            default:
                break;
        }

        if (cssHref != "") {
            $("#linkcss").attr("href", cssHref);
        }
    }

    function rsaFunc(text) {
        var rsa = new RSAKey();

        rsa.setPublic($("#hidN").val(), $("#hidE").val());
        var res = rsa.encrypt(text);

        if (res) {
            return linebrk(hex2b64(res), 64);
        }
        else {
            return "";
        }
    }

    function countdown() {
        $("#getcode").html("倒计时 " + countdownNum);

        if (countdownNum > 0) {
            countdownNum = countdownNum - 1;

            set_cd = setTimeout(countdown, 1000);
        }
        else {
            $("#getcode").removeClass("done");
            $("#getcode").html("获取手机验证码");
        }
    }
</script>
